import request from "@/utils/request";

// 请求学科列表
type subjectParamsType = {
    level?: number | string; //年级
    pageIndex: number;
    pageSize: number
}


type subjectResponseType<T> = {
    total: number,
    list: T[]
}

// 返回学科列表类型
export type subjectType = {
    id: number,
    name: string,  //学科名称
    level: number,  //年级
    levelName: string  //年级名称
}

// 请求学科列表接口
export function subjectPage(data: subjectParamsType) {
    return request.post<subjectResponseType<subjectType>>('/api/admin/education/subject/page', data)
}

  // 修改编辑接口类型定义
  export type subjectParamsAddType = {
    id: number | null,  // 允许id为null或数字
    level: number | string,
    levelName: string,
    name: string
  }
  


//学科添加接口
export function subjectAdd(data: subjectParamsAddType) {
    return request.post<null>('/api/admin/education/subject/edit', data)
}


// 添加学科查询接口
export function subjectSelect(id: number) {
    return request.post<subjectType>(`/api/admin/education/subject/select/`+id)
  }
  


  //学科删除
  export function subjectDelete(id: number) {
    return request.post<null>(`/api/admin/education/subject/delete/` + id)
  }
